<template>
    <div class="photoinfo-container">
        <h3>{{ photoinfo.title }}</h3>
        <p class="subtitle">
            <span>发表时间:{{ photoinfo.add_time  }}</span>
            <span>点击：{{ photoinfo.click }}次</span>
        </p>
        <hr>
        <!-- 缩略图区域 -->
        <div class="thumbs">
        <vue-preview :slides="list" class="imgPrev"></vue-preview> 
        </div>
        
        <!-- 图片内容区域 -->
        <div class="content" v-html="photoinfo.content"></div>
        <!-- 放置一个现成的评论子组件 -->
        <cmt-box :id="id"></cmt-box>
    </div>
</template>

<script>
import comment from '../subcomponents/comment'

export default {
    data(){
        return{
            id: this.$route.params.id,
            photoinfo:{},
            list:[]   //缩略图的数组
        }
    },
    created(){
        this.getPhotoInfo(),
        this.getThumbs()
    },
    methods:{
        getPhotoInfo(){
            this.axios.get('../../../static/api/photoinfo'+this.id+'.json').then((response) => {
            this.photoinfo=response.data
            console.log(response.data)
          }) 
        },
        getThumbs(){
            this.axios.get('../../../static/api/suolvtu.json').then((response) => {
                for(var i=0;i<response.data.length;i++){
                    if(response.data[i].id==this.id) {
                    this.list=this.list.concat(response.data[i])
                    }            
                }     
            })
        }
    },
    components:{
        'cmt-box':comment   
    }
}
</script>

<style lang="scss">
.photoinfo-container{
    padding: 3px;
    h3{
        color: rgb(45, 53, 59);
        font-size: 15px;
        text-align: center;
        margin: 15px 0;
    }
    .subtitle{
        display: flex;
        justify-content: space-between;
    }
    .content{
        font-size: 13px;
        line-height: 30px;
    }
    .thumbs{
        text-align: center;
        margin: 10px;
        padding: 5px 0;
        box-shadow: 0 0 8px #999;
        img{
            width: 80%;
            height: 80%;           
        }
    }
}
</style>